"""抖音开放平台API异常类"""

from ..common.exceptions import APIError, AuthenticationError


class DouYinError(APIError):
    """抖音API基础异常"""
    
    def __init__(self, message, err_no=None, response=None):
        self.err_no = err_no
        super().__init__(message, code=err_no, response=response)


class DouYinAuthError(AuthenticationError, DouYinError):
    """抖音认证错误"""
    
    def __init__(self, message="抖音认证失败", err_no=40001, response=None):
        super().__init__(message, err_no=err_no, response=response)


class DouYinAccessTokenError(DouYinAuthError):
    """AccessToken错误"""
    
    def __init__(self, message="AccessToken获取失败", err_no=40001, response=None):
        super().__init__(message, err_no=err_no, response=response)


class DouYinRateLimitError(DouYinError):
    """请求频率限制错误"""
    
    def __init__(self, message="请求频率过高", err_no=429, response=None):
        super().__init__(message, err_no=err_no, response=response)